package quizman;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dsrg.servlet.app.frontController.Servlet;

import quizman.domain.Quiz;

/**
 * Servlet implementation class ViewAllQuizPageController
 */
public class ViewAllQuizPageController extends Servlet {
	private static final long serialVersionUID = 1L;

	protected void processRequest(
			HttpServletRequest request,
			HttpServletResponse response)
	throws ServletException, IOException //
	{
		try {
			List<Quiz> quizzes = ViewAllQuizTS.execute();
			
			request.setAttribute("quizzes", quizzes);
			getDispatcher("ViewAllQuiz.jsp", request).forward(request, response);
		} catch (Exception e) {
			request.setAttribute("error", e);
			request.setAttribute("message", "Error processing in servlet "+getClass().getSimpleName()+".\n");
			getDispatcher("Error.jsp", request).forward(request, response);
		}
	}

}
